package com.kingdee.pda.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.entity.ReplenishOrderDetailBean.DataBean.ItemsBean;
import com.kingdee.pda.util.ViewHolder;

/**
 * 补货单详情适配器
 * Created by dlj
 * DATE 2021/6/24
 * TIME 10:24
 */
public class ReplenishOrderDetailAdapter extends AbsBaseAdapter<ItemsBean> {

    private final OnSkuItemClickListener onSkuItemClickListener;

    public ReplenishOrderDetailAdapter(Context context, OnSkuItemClickListener onSkuItemClickListener) {
        super(context);
        this.onSkuItemClickListener = onSkuItemClickListener;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.adapter_item_replenish_skulist, null);
        }
        TextView tv_skuCode = ViewHolder.get(convertView, R.id.tv_skuCode);
        TextView tv_specifications = ViewHolder.get(convertView, R.id.tv_specifications);
        TextView tv_skuName = ViewHolder.get(convertView, R.id.tv_skuName);

        try {

            ItemsBean itemsBean = getData().get(position);
            tv_skuCode.setText("SKU编码：" + itemsBean.getItemskuCode());
            tv_specifications.setText("规格名称：" + itemsBean.getItemskuName());
            tv_skuName.setText("商品名称：" + itemsBean.getItemName());

            ViewHolder.get(convertView, R.id.item).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    onSkuItemClickListener.onSkuItemClick(position);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
        return convertView;
    }

    public interface OnSkuItemClickListener {
        void onSkuItemClick(int position);
    }
}
